
package py.una.pol.raphapy.autoventas.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rafael E. Benegas
 */
@Entity
@Table(name = "venta_mercaderia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "VentaMercaderia.findAll", query = "SELECT v FROM VentaMercaderia v"),
    @NamedQuery(name = "VentaMercaderia.findByCodVenVen", query = "SELECT v FROM VentaMercaderia v WHERE v.codVenVen = :codVenVen"),
    @NamedQuery(name = "VentaMercaderia.findByFecVenMer", query = "SELECT v FROM VentaMercaderia v WHERE v.fecVenMer = :fecVenMer"),
    @NamedQuery(name = "VentaMercaderia.findByFecPreVenMer", query = "SELECT v FROM VentaMercaderia v WHERE v.fecPreVenMer = :fecPreVenMer"),
    @NamedQuery(name = "VentaMercaderia.findByEstado", query = "SELECT v FROM VentaMercaderia v WHERE v.estado = :estado")})
public class VentaMercaderia implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_ven_ven")
    private BigDecimal codVenVen;
    @Column(name = "fec_ven_mer")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecVenMer;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fec_pre_ven_mer")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecPreVenMer;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "estado")
    private String estado;
    @ManyToMany(mappedBy = "ventaMercaderiaCollection")
    private Collection<MovimientoMercaderia> movimientoMercaderiaCollection;
    @JoinColumn(name = "cod_ven", referencedColumnName = "cod_ven")
    @ManyToOne(optional = false)
    private Vendedor codVen;
    @JoinColumn(name = "cod_clie", referencedColumnName = "cod_clie")
    @ManyToOne(optional = false)
    private Cliente codClie;

    public VentaMercaderia() {
    }

    public VentaMercaderia(BigDecimal codVenVen) {
        this.codVenVen = codVenVen;
    }

    public VentaMercaderia(BigDecimal codVenVen, Date fecPreVenMer, String estado) {
        this.codVenVen = codVenVen;
        this.fecPreVenMer = fecPreVenMer;
        this.estado = estado;
    }

    public BigDecimal getCodVenVen() {
        return codVenVen;
    }

    public void setCodVenVen(BigDecimal codVenVen) {
        this.codVenVen = codVenVen;
    }

    public Date getFecVenMer() {
        return fecVenMer;
    }

    public void setFecVenMer(Date fecVenMer) {
        this.fecVenMer = fecVenMer;
    }

    public Date getFecPreVenMer() {
        return fecPreVenMer;
    }

    public void setFecPreVenMer(Date fecPreVenMer) {
        this.fecPreVenMer = fecPreVenMer;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<MovimientoMercaderia> getMovimientoMercaderiaCollection() {
        return movimientoMercaderiaCollection;
    }

    public void setMovimientoMercaderiaCollection(Collection<MovimientoMercaderia> movimientoMercaderiaCollection) {
        this.movimientoMercaderiaCollection = movimientoMercaderiaCollection;
    }

    public Vendedor getCodVen() {
        return codVen;
    }

    public void setCodVen(Vendedor codVen) {
        this.codVen = codVen;
    }

    public Cliente getCodClie() {
        return codClie;
    }

    public void setCodClie(Cliente codClie) {
        this.codClie = codClie;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codVenVen != null ? codVenVen.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof VentaMercaderia)) {
            return false;
        }
        VentaMercaderia other = (VentaMercaderia) object;
        if ((this.codVenVen == null && other.codVenVen != null) || (this.codVenVen != null && !this.codVenVen.equals(other.codVenVen))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.raphapy.autoventas.model.VentaMercaderia[ codVenVen=" + codVenVen + " ]";
    }
    
}
